package com.tansun.easycare.rule.common.jfun;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import com.tansun.rule.utils.JavaUnmarshaller;

/**
 * 函数管理
 *
 * @author WY
 */
@XmlRootElement(name = "FunConfig")
public class UserJFunCreator {

    private List<JFun> jFunList = new ArrayList<JFun>();


    @XmlElementWrapper(name = "funs")
    @XmlElement(name = "fun")
    public List<JFun> getjFunList() {
        return jFunList;
    }

    /**
     * set
     */
    public void setjFunList(List<JFun> jFunList) {
        this.jFunList = jFunList;
    }

    /**
     * 自定函数列表
     */
    public static List<JFun> getUserFuns(String userFunPath) throws Exception {
        UserJFunCreator userjfc = (UserJFunCreator) JavaUnmarshaller.xml2Bom(userFunPath, UserJFunCreator.class);
        if (userjfc == null) {
            return new ArrayList<JFun>();
        }
        return userjfc.getjFunList();

    }

}
